home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Chipmunk Basic 3.5.2 / ucase.bas < prev   
BASIC Source File  |  1996-07-27  |  1KB  |  33 lines

  1. 100 rem subroutine tests
  2. 110 b$ = "HelLo"
  3. 120 print countcaps(b$);" capital letters in ";b$
  4. 130 print ucase$(b$);" is all capital letters"
  5. 140 print "{";spc$(4);"} should be 4 spaces between the brackets"
  6. 150 for i = 1 to 10 : print fib(i); : next i : print " are fibonacci numbers"
  7. 190 end
  8. 191 '********
  9. 8000 sub fib(n) : rem recursive fibonacci number
  10. 8010   if n < 2 then return (1)
  11. 8020 return (fib(n-1)+fib(n-2))
  12. 9000 sub ucase$(a$,b$,i,c,n) : rem convert a$ to upper case
  13. 9010   b$ = ""
  14. 9020   n = len(a$)
  15. 9030   for i = 1 to n
  16. 9040     c = asc(mid$(a$,i,1))
  17. 9050     if c > 96 then c = c-32
  18. 9060     b$ = b$+chr$(c)
  19. 9070   next i
  20. 9080 return (b$)
  21. 9100 sub countcaps(a$,i,n,c$) : rem count capital letters in a$
  22. 9110   n = 0
  23. 9120   for i = 1 to len(a$)
  24. 9130     c$ = mid$(a$,i,1) : if c$ >= "A" and c$ <= "Z" then n = n+1
  25. 9140   next i
  26. 9150 return (n)
  27. 9200 sub spc$(n,b$,i) : rem create a string of n spaces
  28. 9210   b$ = ""
  29. 9220   for i = 1 to n : b$ = b$+" " : next i
  30. 9230 return (b$)
  31. 9980 '********
  32. 9990 end
  33.